package com;

import com.android.antelopeapp.network.UploadUtil;
import com.google.gson.Gson;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import com.taobao.tae.sdk.TaeSDK.*;

/**
 * Created by WEBUSER on 2014/12/18.
 */
public class Test {
    public static final String TAG="TEST";
    public static void testGSon(){
        Gson gson = new Gson();
        String json = "{\"message\":\"not_end\",\"result\":true,\"customData\":[{\"content\":\"\",\"id\":\"5005BE797D3A4B989EC16B675C68759A\",\"author\":\"lyp\",\"isComplete\":\"\",\"rank\":0,\"share\":0,\"title\":\"百行孝为先，从走心的小礼物做起\",\"mainpic\":\"/raPic/5005BE797D3A4B989EC16B675C68759A.jpg\",\"isChecked\":0,\"typeid\":\"D7F16502C22C453BB8875C6D64674E43\",\"crtime\":{\"nanos\":0,\"time\":1418093623000,\"minutes\":53,\"seconds\":43,\"hours\":10,\"month\":11,\"timezoneOffset\":-480,\"year\":114,\"day\":2,\"date\":9},\"collect\":0},{\"content\":\"\",\"id\":\"6FA1B0B1B73F47AFBC6CFFE1E3BC4128\",\"author\":\"lyp\",\"isComplete\":\"\",\"rank\":0,\"share\":0,\"title\":\"冰心一片诉相思：来自“心”的礼\",\"mainpic\":\"/raPic/6FA1B0B1B73F47AFBC6CFFE1E3BC4128.jpg\",\"isChecked\":0,\"typeid\":\"8C2BBFC74EC245C69085AE6F57C0BA9E\",\"crtime\":{\"nanos\":0,\"time\":1418048710000,\"minutes\":25,\"seconds\":10,\"hours\":22,\"month\":11,\"timezoneOffset\":-480,\"year\":114,\"day\":1,\"date\":8},\"collect\":0},{\"content\":\"\",\"id\":\"93D30FD49C4A47D697E49723A893B714\",\"author\":\"lyp\",\"isComplete\":\"\",\"rank\":0,\"share\":0,\"title\":\"送Ta一片宇宙，我们一起遨游\",\"mainpic\":\"/raPic/93D30FD49C4A47D697E49723A893B714.jpg\",\"isChecked\":0,\"typeid\":\"BFF44B47EB004183818DC819A33B640A\",\"crtime\":{\"nanos\":0,\"time\":1418048693000,\"minutes\":24,\"seconds\":53,\"hours\":22,\"month\":11,\"timezoneOffset\":-480,\"year\":114,\"day\":1,\"date\":8},\"collect\":0},{\"content\":\"\",\"id\":\"ED0E27F0E2EE4B959149057C82A39BFE\",\"author\":\"lyp\",\"isComplete\":\"\",\"rank\":0,\"share\":0,\"title\":\"用项链表爱意，别让她的脖子空着\",\"mainpic\":\"/raPic/ED0E27F0E2EE4B959149057C82A39BFE.jpg\",\"isChecked\":0,\"typeid\":\"CB6332873C34463597F51D8C29F2CF0F\",\"crtime\":{\"nanos\":0,\"time\":1418047848000,\"minutes\":10,\"seconds\":48,\"hours\":22,\"month\":11,\"timezoneOffset\":-480,\"year\":114,\"day\":1,\"date\":8},\"collect\":0},{\"content\":\"\",\"id\":\"FCD4134DB4414199A7F04931678B7A1B\",\"author\":\"lyp\",\"isComplete\":\"\",\"rank\":0,\"share\":0,\"title\":\"送给永远缺一块皂的皂控们\",\"mainpic\":\"/raPic/FCD4134DB4414199A7F04931678B7A1B.jpg\",\"isChecked\":0,\"typeid\":\"4AF6950BB7984CD38874F54D94BA42F8\",\"crtime\":{\"nanos\":0,\"time\":1418047781000,\"minutes\":9,\"seconds\":41,\"hours\":22,\"month\":11,\"timezoneOffset\":-480,\"year\":114,\"day\":1,\"date\":8},\"collect\":0}]}";
    }
    public static void testUploadUntil(){
        UploadUtil upUntil = UploadUtil.getInstance();
        String fileName1 = "/home/phk/images/1.jpg";
        String fileName2 = "/home/phk/images/2.jpg";
        String fileKey = "file";
        String url = "http://210.32.133.23:8180/lyhw/bpic/save.app";

        Map<String,String> map = new HashMap<>();
        map.put("content","Hello");
        upUntil.setOnUploadProcessListener(new UploadUtil.OnUploadProcessListener() {
            @Override
            public void onUploadDone(int responseCode, String message) {
                System.out.print("onUploadDone ,code:" + responseCode + " message:" + message);
            }

            @Override
            public void onInitUpload() {
            }
        });
        ArrayList<UploadUtil.FileBean> list = new ArrayList<UploadUtil.FileBean>();
        list.add(new UploadUtil.FileBean(fileName1,fileKey+"1"));
        list.add(new UploadUtil.FileBean(fileName2,fileKey+"2"));
        upUntil.uploadFile(list,url,map);
    }
    public static void main(String[] args) {
        testUploadUntil();
    }
}
